<!DOCTYPE html>
<html>
<head>
    <title>告警渠道</title>
    <#include "/header.html">
    <link rel="stylesheet" href="${request.contextPath}/statics/plugins/bootstrap-select/css/bootstrap-select.min.css?_${.now?long}">
    <style>
        /*去除选择框的outline*/
        .bootstrap-select .dropdown-toggle:focus{outline:none !important;}
        /*去除选项的outline*/
        a:focus {outline:none !important;}
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <div class="form-group col-sm-2">
                <input type="text" class="form-control" v-model="q.name" @keyup.enter="query" placeholder="渠道名称">
            </div>
            <a class="btn btn-default" @click="query">查询</a>
            <#if shiro.hasPermission("monitor:notification:add")>
            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
        </#if>
        <#if shiro.hasPermission("monitor:notification:update")>
        <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
    </#if>
    <#if shiro.hasPermission("monitor:notification:delete")>
    <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
</#if>
</div>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>

<div v-show="!showList" class="panel panel-default">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal" style="width: 700px;">
        <div class="form-group">
            <div class="col-sm-2 control-label">渠道名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="notification.name" placeholder="渠道名称"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">渠道类型</div>
            <div class="col-sm-10">
                <select id="typeSelect" class="selectpicker form-control" v-model="notification.type" width="100%">
                    <option v-for="(item,index) in typeList" :key="index" :value="item.value" :disabled="item.disabled">{{item.label}}</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">是否接收所有告警</div>
            <div class="col-sm-10">
                <label class="radio-inline">
                    <input type="radio" name="isDefault" value="1" v-model="notification.isDefault">是
                </label>
                <label class="radio-inline">
                    <input type="radio" name="isDefault" value="0" v-model="notification.isDefault">否
                </label>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">是否启用告警压缩</div>
            <div class="col-sm-10">
                <label class="radio-inline">
                    <input type="radio" name="sendReminder" value="1" v-model="notification.sendReminder">是
                </label>
                <label class="radio-inline">
                    <input type="radio" name="sendReminder" value="0" v-model="notification.sendReminder">否
                </label>
            </div>
        </div>
        <div class="form-group" v-show="notification.sendReminder === '1'">
            <div class="col-sm-2 control-label">发送频率</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="notification.frequency" placeholder="压缩频率"/>
            </div>
        </div>
        <!--email settings-->
        <div class="form-group" v-show="notification.type === 'email'">
            <div class="col-sm-2 control-label">email地址</div>
            <div class="col-sm-10">
                <textarea class="form-control" rows="3" v-model="emailSettings" placeholder="邮箱地址，多个邮箱使用英文逗号隔开"></textarea>
            </div>
        </div>

        <!--webhook settings-->
        <div class="form-group" v-show="notification.type === 'webhook'">
            <div class="col-sm-2 control-label">webhook接口地址</div>
            <div class="col-sm-10">
                <input type="text" class="form-control" v-model="webhookSettings.url" placeholder="webhook接口地址（暂时只支持POST）"/>
            </div>
        </div>

        <!--dingtalk settings-->
        <div v-show="notification.type === 'dingtalk'">
            <div class="form-group">
                <div class="col-sm-2 control-label">dingtalk接口地址</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="dingtalkSettings.url" placeholder="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxx"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">dingtalk机器人密钥</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="dingtalkSettings.secret" placeholder="暂时只支持加签模式"/>
                </div>
            </div>
            <div class="form-group" hidden>
                <div class="col-sm-2 control-label">消息类型</div>
                <div class="col-sm-10">
                    <select id="dingtalkMsgType" class="selectpicker form-control" v-model="dingtalkSettings.messageType" width="100%">
                        <option v-for="(item,index) in dingtalkMsgTypeList" :key="index" :value="item.value">{{item.label}}</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
            <input type="button" class="btn btn-warning" @click="reload" value="返回"/>
        </div>
    </form>
</div>
</div>

<script src="${request.contextPath}/statics/js/modules/monitor/rule.js?_${.now?long}"></script>
<script src="${request.contextPath}/statics/plugins/bootstrap-select/js/bootstrap-select.min.js?_${.now?long}"></script>
<script src="${request.contextPath}/statics/plugins/bootstrap-select/js/i18n/defaults-zh_CN.min.js?_${.now?long}"></script>
</body>
</html>